{
  "properties" : { },
  "id" : "6521572bd9334bd59d7648ac47e79c2e",
  "script" : null,
  "groupId" : "1f1767129e1243fe91e873f62d6954d2",
  "name" : "mongo",
  "createTime" : null,
  "updateTime" : 1648122258582,
  "lock" : null,
  "createBy" : "666",
  "updateBy" : "admin",
  "path" : "/mongo",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"message\": \"success\",\n    \"data\": [],\n    \"timestamp\": 1648122249993,\n    \"executeTime\": 5887\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Array",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "timestamp",
      "value" : "1648122249993",
      "description" : "",
      "required" : false,
      "dataType" : "Long",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "executeTime",
      "value" : "5887",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
/*
 !!!!!! DEMO网站未集成Mongo，以下只是作为示例，无法执行。
*/
import mongo;   //导入mongodb模块
import mongoTemplete;//自定义的模块
import log;//日志模块

import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.mongodb.core.query.Criteria;


import org.springframework.data.mongodb.core.aggregation.Aggregation;

import org.apache.commons.collections.CollectionUtils;

var collectionName = "yqfk_sentinel_surveillance";
var total = new Query();
total.addCriteria(Criteria.where("delFlag").is(0))
var count = mongoTemplete.count(total,null,collectionName)

//修改
var query = new Query(Criteria.where("_id").is("123"));
//使用自定义函数
var userName = getUserInfo().userName;
log.info("userName:"+userName);
var update = new Update();
update.set("updateBy",userName!=null?userName:'')
update.set("updateTime",now())

mongoTemplete.update(query,update,"yqfk_sentinel_surveillance");

var tableName = "yqfk_sentinel_surveillance";
// mongoTemplete.aggregate(query,tableName)
var objectList = mongoTemplete.aggregate(
    Aggregation.newAggregation(
        Aggregation.unwind("personList"),

        Aggregation
            .addFields()
            .addFieldWithValue("dangerPersonName","$personList.dangerPersonName")
            .addFieldWithValue("dangerPersonPhone","$personList.dangerPersonPhone")
            .addFieldWithValue("dangerPersonAddr","$personList.dangerPersonAddr")
            .build(),

        Aggregation.project("sentinelName","sentinelType")
    ),tableName).mappedResults;

if (CollectionUtils.isNotEmpty(objectList)) {
    objectList.forEach(o -> {
        o["_id"] = o["_id"].toString()
    });
}

// objectList.stream().map(arg0)

//return mongo.test.col1.insert({name : 'magic'});
return mongo.test.col1.find({name : 'magic'}).list();